import React from 'react';

export default {
  strategy(props) {
    const { node } = props;
    const { label = '', required } = node.data;
    if (label || required) {
      return true;
    }
    return false;
  },
  component(props) {
    const { node } = props;
    let { label = '' } = node.data;
    const { required, labelMargin } = node.data;
    if (label) {
      label = `${label}:`;
    }else if(required) {
      label = ':';
    } else {
      label = '';
    }
    return (
      <>
        <span style={{ paddingRight: `${labelMargin}px`, flexShrink: 0 }}>{required ? <span style={{ fontWeight: 600, color: 'red', marginRight: 4, fontSize: '16px' }}>*</span> : null}{label}</span>
        {props.children}
      </>
    );
  },
};
